/**
    Copyright (c) 2009 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

/**
    @file   
    @brief  Draw a texture full screen.
            Based on code from the Microsoft SDK HDRTonemappingCS11 sample.
    @author yakiimo02
    @date   09/11/23
*/

struct QuadVS_Input
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD0;
};

struct QuadVS_Output
{
    float4 Pos : SV_POSITION;              
    float2 Tex : TEXCOORD0;
};

/** Vertex Shader */

QuadVS_Output QuadVS( QuadVS_Input Input )
{
    QuadVS_Output Output;
    Output.Pos = Input.Pos;
    Output.Tex = Input.Tex;
    return Output;
}

/** Pixel Shader */

StructuredBuffer<unsigned int> buffer : register( t0 );

float4 QuadPS( QuadVS_Output Input ) : SV_TARGET
{
    // convert tex coord to buffer index
    float2 index2 = float2( 511, 511 ) * Input.Tex.xy;
    float index = index2.y * 512 + index2.x;
    float4 vColor = buffer[ index ] / (512.0f*512.0f);
    return vColor;
}